package com.fling.abcde;

import android.app.Application;
import android.content.Context;

import com.fling.abcde.bean.UserResBean;
import com.lib.utils.ActivityLifecycleUtils;
import com.lib.utils.SPUtils;
import com.lib.utils.XLog;

/**
 * @author FengLing
 * Created on 2016-12-03 20:33
 */
public class BaseApplication extends Application {
    public static Context sContext;

    public static UserResBean.DataEntity sUser;
    public static String sToken;

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
    }

    @Override
    public void onCreate() {
        super.onCreate();
        sContext = getApplicationContext();

        boolean debug = XLog.init(this, "Base", BuildConfig.DEBUG);

        ErrorReport.init();

        ActivityLifecycleUtils.init(this, debug);

        SPUtils.init(this);

        sToken = SPUtils.getSP().getString(SPUtils.KEY_LAST_TOKEN, null);
    }

    public static void safeExitApp() {
        ActivityLifecycleUtils.finishAll();
        LocationInfoManager.exit();
        android.os.Process.killProcess(android.os.Process.myPid());
        System.exit(0);
    }

}